class AnimalShelf {
public:
    queue<pair<int,int>> cat;
    queue<pair<int,int>> dog;
    AnimalShelf() {
    }
    
    void enqueue(vector<int> animal) {
        if(animal[1] == 0)
        {
            cat.push(make_pair(animal[0],0));
        }
        else
        {
            dog.push(make_pair(animal[0],1));
        }
        
    }
    
    vector<int> dequeueAny() 
    {
        if(!cat.empty()&&!dog.empty())
        {
            auto tmp_dog = dog.front();
            auto tmp_cat = cat.front();
            //狗先来
            if(tmp_dog.first<tmp_cat.first)
            {
                dog.pop();
                vector<int> ret(2);
                ret[0] = tmp_dog.first;
                ret[1] = tmp_dog.second;
                return ret;
            }
            else
            {
                //猫先来
                cat.pop();
                vector<int> ret(2);
                ret[0] = tmp_cat.first;
                ret[1] = tmp_cat.second;
                return ret;
            }
        }
        //判断两个是否都为空
        if(dog.empty()&&cat.empty())
        {
            return {-1,-1};
        }
        //其中一个为空
        auto tmp = dog.empty()?cat.front():dog.front();
        if(!dog.empty())
        {
            dog.pop();
        } 
        else
        {
            cat.pop();
        }
        return {tmp.first,tmp.second};
    }
    
    vector<int> dequeueDog() 
    {
        if(dog.empty())
        {
            return {-1,-1};
        }    
        auto tmp = dog.front();
        dog.pop();
        return {tmp.first,tmp.second};
    }
    
    vector<int> dequeueCat() {
        if(cat.empty())
        {
            return {-1,-1};
        }
        auto tmp = cat.front();
        cat.pop();
        return {tmp.first,tmp.second};
    }
};

/**
 * Your AnimalShelf object will be instantiated and called as such:
 * AnimalShelf* obj = new AnimalShelf();
 * obj->enqueue(animal);
 * vector<int> param_2 = obj->dequeueAny();
 * vector<int> param_3 = obj->dequeueDog();
 * vector<int> param_4 = obj->dequeueCat();
 */